import React, { useState } from 'react'
import {
  Form,
  Input,
  Button,
  NavBar,
  Checkbox,
} from 'antd-mobile'
import styles from './register.module.scss'
import axios from '../../api/axios'
import { useNavigate } from 'react-router-dom'
const Index = () => {
   let navigate=useNavigate()
  const onFinish = async (values) => {
  const res=await axios.post('/tx/register',values)
  console.log(res);
  }
  const handelgo=()=>{
    navigate('/login')
  }
  return (
    <div className={styles.logbox}>

      <NavBar back='取消' backIcon={false}>
      </NavBar>
      <div className={styles.logform}>
        <h2>注册春雨医生</h2>
        <Form
          layout='horizontal'
          className={styles.form}
          onFinish={onFinish}
          footer={
            <div>
              <Button block type='submit' color="success" size='large'>
                注册
              </Button>
            </div>

          }
        >
          <Form.Item
            // className={styles.form_item}
            name='username'
            label='姓名'
            rules={[{ required: true, message: '姓名不能为空' }]}
          >
            <Input  placeholder='请输入姓名' />
          </Form.Item>
          <Form.Item
            name='password'
            label='密码'
            rules={[{ required: true, message: '姓名不能为空' }]}
          >
            <Input  placeholder='请输入密码' />
          </Form.Item>
          <Form.Item
            name='nickname'
            label='昵称'
            rules={[{ required: true, message: '昵称不能为空' }]}
          >
            <Input  placeholder='请输入昵称' />
          </Form.Item>
           <Form.Item
            name='avatar'
            label='头像'
            rules={[{ required: true, message: '头像不能为空' }]}
          >
            <Input  placeholder='请输入头像网址' />
          </Form.Item>
        </Form>
        <p className={styles.registe} onClick={handelgo}>以注册成功？，登录新账号</p>
      </div>

    </div>
  )
}

export default Index
